# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=cecster
pkgver=5.15544cb
pkgrel=7
groups=('blackarch' 'blackarch-scanner' 'blackarch-fuzzer')
pkgdesc='A tool to perform security testing against the HDMI CEC (Consumer Electronics Control) and HEC (HDMI Ethernet Channel) protocols.'
arch=('any')
url='https://github.com/nccgroup/CECster'
license=('GPL3')
depends=('python2' 'python2-pyserial' 'wxpython' 'python2-pyusb')
makedepends=('git')
provides=('cecster')
source=("$pkgname::git+https://github.com/nccgroup/CECster.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare(){
  cd $pkgname

  sed -i 's/.$//' CECSTeR.py
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -dm 755 "$pkgdir/usr/share/$pkgname/images"

  install -Dm 644 "HDMI_Ethernet_Channel_whitepaper.pdf" \
    "$pkgdir/usr/share/doc/$pkgname/HDMI_Ethernet_Channel_whitepaper.pdf"

  cp -a images/* "$pkgdir/usr/share/$pkgname/images/"
  cp -a CECSTeR.py "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
cd /usr/share/$pkgname
exec python2 CECSTeR.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

